<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		
		<!-- 侦听器的应用场景：异步或者开销比较大的操作 -->
		<!-- 监听数据的变化 -->
		
		<div id="app">
			姓: <input type="text" name="" id="" value="" v-model="firstname" /><br>
			名: <input type="text" name="" id="" value=""  v-model="lastname"/>
			<p>{{fullname}}</p>
		</div>
		<script src="../vue.js"></script>
		<script type="text/javascript">
			var vm = new Vue({
				el: "#app",
				data: {
					firstname: 'w',
					lastname: 'rt',
					fullname: 'wrt'
				},
				methods: {},
				watch: {
					firstname: function(val) {
						this.fullname = val + ' ' + this.lastname
					},
					lastname: function(val) {
						this.fullname = this.firstname+ ' ' + val
					}
				}
			})
		</script>
	</body>
</html>

